define(function (require, exports, module) {
    var angular = require('angular');
    require('angular-route');
    require('/public/js/myservice/backlog/backlog-list-ctrl');
    require('/public/js/myservice/backlog/backlog-list-have-done-ctrl');
    require('/public/js/myservice/contract/contract-ctrl');
    require('/public/js/myservice/contract/contract-caibao-ctrl');
    require('/public/js/myservice/invoice/list');
    require('/public/js/myservice/balance/list');
    require('/public/js/myservice/mytest/mytest-list-ctrl');
    require('/public/js/myservice/abnormal/violated-contract-list');
    require('/public/js/myservice/abnormal/special-invoice-list');
    require('/public/js/myservice/abnormal/special-authorize-list');
    require('/public/js/myservice/tenant');
    require('/public/js/myservice/refund/index');
    require('/public/js/myservice/expcenter/index');
    require('/public/js/myservice/confirm/index');
    require('/public/js/myservice/income/income-list');
    require('/public/js/myservice/params/carryovertime');
    require('/public/js/myservice/params/balancerate');
    require('/public/js/myservice/reports/reports-ctrl');

    var util = require("util");
    var api_prefix = G_CONFIG["api_prefix"]; //api前缀

    angular.module('myBackendApp', ['ngRoute','backlog','backlogHaveDone', 'Contract','ContractCaibao', 'Invoice', 'Balance', 'ViolatedContract', 'SpecialInvoice', 'SpecialAuthorize', 'Tenant', 'Refund', 'Confirm', 'ExpCenter','mytest','IncomeInfor','ParamsInfor','ParamsInfor2','reports'])
        .factory('config', function () {
            return {
                app: {
                    name: '明源云链管理后台',
                    description: '明源云链'
                },
                user: {
                    name: '管理员',
                    picture: ''
                }
            };
        })
        .config(['$routeProvider',
            function ($routeProvider) {
                $routeProvider
                    .when("/", {redirectTo: '/contract'})
                    .when('/backlog',{
                        templateUrl:'backlog/list.html',
                        controller: 'backlogListCtrl'
                    })
                    .when('/backlog/have-done',{
                        templateUrl:'backlog/editinc/list.html',
                        controller: 'backlogListHaveDoneCtrl'
                    })
                    .when('/contract', {
                        templateUrl: 'contract/list.html',
                        //controller: 'contractListCtrl',
                        resolve: {
                            'test': function () {
                                return {name: '333334444'};
                            }
                        }
                    })
                    .when('/caibao',{
                        templateUrl:'contract/list_caibao.html',
                        controller: 'contractListCaibaoCtrl'
                    })
                    .when('/balance', {
                        templateUrl: 'balance/list.html'
                        //controller: 'balanceListCtrl'
                    })
                    .when('/invoice', {
                        templateUrl: 'invoice/list.html'
                        //controller: 'invoiceListCtrl'
                    })
                    .when('/incomeall',{
                        templateUrl: 'income/list.html',
                        controller: 'incomeListCtrl'
                    })
                    .when('/incomewaitconfirm',{
                        templateUrl: 'income/list.html',
                        controller: 'incomeListCtrl'
                    })
                    .when('/incomehaveconfirm',{
                        templateUrl: 'income/list.html',
                        controller: 'incomeListCtrl'
                    })
                    .when('/incomehaveclose',{
                        templateUrl: 'income/list.html'
                    })
                    .when('/violated_contract', {
                        templateUrl: 'abnormal/violated_contract_list.html',
                        controller: 'violatedContractListCtrl'
                    })
                    .when('/special_approval_invoice', {
                        templateUrl: 'abnormal/special_invoice_list.html',
                        controller: 'specialInvoiceListCtrl'
                    })
                    .when('/special_approval_authorize', {
                        templateUrl: 'abnormal/special_authorize_list.html',
                        controller: 'specialAuthorizeListCtrl'
                    })
                    .when('/mytest', {
                        templateUrl: 'mytest/list.html',
                        controller: 'mytestListCtrl'
                    })
                    .when('/tenant', {
                        templateUrl: 'tenant/list.html',
                        controller: 'tenantCtl'
                    })
                    .when('/refund', {
                        templateUrl: 'refund/index.html',
                        controller: 'refundCtl'
                    })
                    .when('/confirm', {
                        templateUrl: 'confirm/index.html',
                        //controller: 'confirmCtl'
                    })
                    .when('/expcenter', {
                        templateUrl: 'expcenter/expcenter.html'
                    }).when('/export', {
                        templateUrl: 'export/export.html'
                    })
                    .when('/params_carryovertime', {
                        templateUrl: 'params/carryovertime.html',
                        controller: 'paramsCarryoverCtrl'
                    })
                    .when('/params_balancerate', {
                        templateUrl: 'params/balancerate.html',
                        controller: 'paramsBalancerateCtrl'
                    })
                    .when('/reports', {
                        templateUrl: 'reports/reports.html',
                        controller: 'reportsCtrl'
                    })
                ;
            }])
        .service('appservice', function ($rootScope) {
            return {name: '明源云链'};
        })
        .controller('appctrl', ['$scope', 'appservice', function ($scope, appservice) {
            $scope.app = appservice;

            //$scope.staticweburl = '';
            //
            //$scope.geturl = function() {
            //    try{
            //        util.myAjax({
            //            url: api_prefix + "site/get-static-url",
            //            type: "post",
            //            dataType: "json",
            //            data: {},
            //            success: function (res) {
            //                if (res['retCode'] == 0) {
            //                    $scope.staticweburl = res['data'];
            //                    util.alert($scope.staticweburl);
            //                } else {
            //                    util.alert('未配置静态资源站点,请检查!');
            //                    $scope.staticweburl = '';
            //                }
            //            }
            //        });
            //    }catch (ex){
            //        $scope.staticweburl = '';
            //    }
            //};
            //$scope.geturl();
        }]);
    angular.bootstrap(document, ['myBackendApp']);
});